package com.hk.controller.admin;

import com.hk.model.pojo.SysDictData;
import com.hk.model.pojo.SysDictType;
import com.hk.result.PageResult;
import com.hk.result.Result;
import com.hk.service.DictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "字典类型管理")
@RestController
@RequestMapping("/system/dict/type")
@Slf4j
public class DictTypeController {

    @Autowired
    private DictTypeService dictTypeService;

    @ApiOperation("分页条件查询")
    @GetMapping("/list")
    public PageResult selectDictTypeByPage(Integer pageNum, Integer pageSize, String dictName, String dictType, Integer status, String beginTime, String endTime) {
        PageResult pageResult = dictTypeService.selectDictTypeByPage(pageNum, pageSize, dictName, dictType, status, beginTime, endTime);
        return pageResult;
    }

    @ApiOperation("新增字典类型")
    @PostMapping
    public Result<String> addDictType(@RequestBody SysDictType sysDictType) {
        dictTypeService.addDictType(sysDictType);
        return Result.success();
    }

    @ApiOperation("根据id查询字典类型")
    @GetMapping("/{dictId}")
    public Result<SysDictType> getDictTypeById(@PathVariable Long dictId) {
        SysDictType sysDictType = dictTypeService.getDictTypeById(dictId);
        return Result.success(sysDictType);
    }

    @ApiOperation("修改字典类型")
    @PutMapping
    public Result<String> updateDictType(@RequestBody SysDictType sysDictType) {
        dictTypeService.updateDictType(sysDictType);
        return Result.success();
    }

    @ApiOperation("批量删除字典类型")
    @DeleteMapping("/{ids}")
    public Result<String> deleteDictType(@PathVariable Long[] ids) {
        dictTypeService.deleteDictType(ids);
        return Result.success();
    }


}
